/**
 * fulihui.com Inc.
 * Copyright (c) 2015-2016 All Rights Reserved.
 */
package com.fulihui.integral.core.biz.conv;

import com.fulihui.integral.core.dal.dataobj.ISStatInfo;
import com.fulihui.integral.core.dto.ISStatInfoDTO;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 按天统计收支 转换类
 * @author zhangyingjie
 * @version $Id: v 0.1 2017年04月13日 18:47 zhangyingjie Exp $
 */
public class ISStatInfoConvert {
    /**
     * 不copy的属性数组
     */
    private static final String[] ignoreProperties = {};

    /**
     * DTO转换成DO
     *
     * @param source
     * @return
     */
    public static ISStatInfo convertDTO2DO(ISStatInfoDTO source) {
        if (source == null) {
            return null;
        }
        ISStatInfo target = new ISStatInfo();
        BeanUtils.copyProperties(source, target);
        return target;
    }

    /**
     * DO转换成DTO
     *
     * @param source
     * @return
     */
    public static ISStatInfoDTO convertDO2DTO(ISStatInfo source) {
        if (source == null) {
            return null;
        }
        ISStatInfoDTO target = new ISStatInfoDTO();
        BeanUtils.copyProperties(source, target);
        return target;
    }

    /**
     * doList转换为dtoList
     * @param list
     * @return
     */
    public static List<ISStatInfoDTO> convert2List(List<ISStatInfo> list) {
        return list.stream().map(ISStatInfoConvert::convertDO2DTO).collect(Collectors.toList());

    }
    /**
     * dtoList转换为doList
     * @param list
     * @return
     */
    public static List<ISStatInfo> convertdto2doList(List<ISStatInfoDTO> list) {
        return list.stream().map(ISStatInfoConvert::convertDTO2DO)
                .collect(Collectors.toList());
    }
}
